<?php

session_start();
$_SESSION["previouspage"] = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];//remembers the url of this page, used for redirect.

if (!isset($_GET['label']) ) {
	header('Location: ./');
}
$tag = (string)(urldecode($_GET['label']));

require_once 'include/config.lib.php';
require_once 'include/database.lib.php';
require_once 'include/tags.php';

ConnectToDB();// Connect to the DB.

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="css/template.css" />
<link rel="stylesheet" type="text/css" href="css/home.css" />
<link rel="stylesheet" type="text/css" href="css/paper_view.css" />
<link rel="stylesheet" type="text/css" href="css/conv_styles.css" />
<link rel="stylesheet" type="text/css" href="css/network_styles.css" />
<link rel="stylesheet" type="text/css" href="third_party/jquery-ui-1.8.5/jquery-ui-1.8.5.custom.css" />


<title>Papers Tagged by '<?php echo $tag?>' - CoRAL Reporter</title>
</head>
<body >
<?php //to determine whether a user has logged in or not, which will output different buttons
if(isset($_SESSION["accountNo"]))	
{	
	$inorout = "controller/logout.php";	
	$display = "Log out";
}
else
{	
	$inorout = "login.php";
	$display = "Log in";
}
?>
	<div id="body-wrapper">
		<?php include_once 'static/header.php'; ?>
		<div id="body">
		
		<div id="result-section" class="section">
			<ul class="list">
			<?php
			 $stmt = papersTaggedBy($tag);
			while($row = $stmt->fetchAssocRow()) { 
				?>
				<li> <!-- List of the users reviewed papers -->
					
					<!--<div class="rating"><!?php echo empty($row['TOTAL']) ? "N/A" : $row['TOTAL']; ?></div><br>
					-->
					<a href="paper_view.php?id=<?php echo $row['BIBTEXID']; ?>"><span class="title"><?php echo (empty($row['TITLE'])) ? "Paper ".$row['BIBTEXID'] : htmlentities($row['TITLE']); ?></span></a>
					<div class="abstract">
					<?php echo empty($row['ABSTRACT']) ? 'No abstract available.' : 'Abstract: '.htmlentities(substr($row['ABSTRACT'],0, min(strlen($row['ABSTRACT']), 200)).'...'); ?>					
					</div>
				</li>
			<?php
			} ?>
			</ul>
			</div>
		</div>
	<?php include_once 'static/footer.html'; ?>
	</div>
</body>
</html>
